package com.kevin.mybatis.controller;

import com.kevin.mybatis.model.DataScope;
import com.kevin.mybatis.model.LoginUser;
import com.kevin.mybatis.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户管理")
@RestController
@AllArgsConstructor
@RequestMapping("/user")
public class UserController {

    private final UserService userService;

    @Operation(summary = "设置数据范围", description = "设置数据范围")
    @PostMapping("/dataScope")
    public void getUser(DataScope dataScope) {
        userService.datascope(dataScope);
    }

    @Operation(summary = "获取当前用户", description = "获取当前用户")
    @GetMapping("/info")
    public LoginUser getUser() {
        return userService.getLoginUser();
    }

}
